<!DOCTYPE html>
<html lang="cn" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{_fragments::common_header(~{::title})}">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>贴子管理 - 逍遥论坛</title>
<link href="../../static/css/bootstrap.min.css"
	th:href="@{/static/css/bootstrap.min.css}" rel="stylesheet">
<script src="../../static/js/jquery-3.2.1.js"
	th:src="@{/static/js/jquery-3.2.1.js}"></script>
<script src="../../static/js/bootstrap.min.js"
	th:src="@{/static/js/bootstrap.min.js}"></script>
</head>
<style>
li {
	list-style-type: none;
}

a {
	color: #8A8A8A;
	cursor: pointer;
}

th {
	text-align: center; /*设置水平居中*/
	/* vertical-align:middle; */ /*设置垂直居中*/
}

td {
	text-align: center; /*设置水平居中*/
	/* vertical-align:middle; */ /*设置垂直居中*/
	border: 1px solid gray;
}
</style>
<body>

	<!-- 弹出结果 -->
	<c:if test="${not empty myInfo}">
		<script type="text/javascript" language="javascript">
			{
				alert("<%=request.getAttribute("myInfo")%>");
			}
		</script>
	</c:if>

	<!-- 引入header文件 -->
	<header th:replace=" _fragments:: header"></header>

	<div class="panel panel-default"
		style="width: 90%; margin-left: 5%; margin-right: 5%; margin-bottom: 5%">
		<div class="panel-heading" style="background-color: #fff">
			<h3 class="panel-title">贴子管理</h3>
		</div>
		<div class="panel-body">

			<!-- 这里显示所有贴子信息 -->
			<table class="table">
				<thead>
					<tr>
						<th
							th:if="${myTip!=2}">ID</th>
						<th>所属分类</th>
						<th>标题</th>
						<th>内容</th>
						<th>发表人</th>
						<th>回复数</th>
						<th>发表时间<br>更新时间
						</th>
						<th>点击数</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<!-- 这里是表格内容，需要遍历数组 -->
					<!-- <c:forEach items="${tips}" var="tip"> --><!-- ||(session.user.userType==0||session.user.userType==1) -->
						<tr th:each="tip,iterStat:${tips}" th:if="${myTip!=2||tip.tipIsdeleted!=1||(session.user.userType==0||session.user.userType==1)}">
							<td	th:if="${myTip!=2}"
								th:text="${tip.tipId}"></td>
							<td th:text="${tip.tabName}"></td>
							<!-- 标题 -->
							<td	
								style="overflow: hidden; text-overflow: ellipsis; max-width: 120px; white-space: nowrap"
								th:text="${tip.tipTitle}"></td>
							<!-- 内容 -->
							<td
								style="overflow: hidden; text-overflow: ellipsis; max-width: 120px; white-space: nowrap"
								th:text="${tip.tipContent}"></td>
							<td th:text="${tip.userName}"><c:choose>
									<c:when test="${not empty tip.user.user_nick}">${tip.user.user_nick}</c:when>
									<c:otherwise>${tip.user.user_name}</c:otherwise>
								</c:choose></td>
							<td th:text="${tip.tipReplies}"></td>
							<td><span
								th:text="${#dates.format(tip.tipPublishtime,'yyyy-MM-dd')}"></span>
								<br> <span
								th:text="${#dates.format(tip.tipModifytime,'yyyy-MM-dd')}"></span>
							</td>
							<td th:text="${tip.tipClick}"></td>
							<td>
								<!-- <c:choose>
                                <c:when test="${tip.tip_isDeleted == 1}">删除</c:when>
                                <c:otherwise>正常</c:otherwise>
                            </c:choose> -->
								<div th:switch="${tip.tipIsdeleted}">
									<span th:case="1">删除</span> <span th:case="*">正常</span>
								</div> <br> <!--     <c:choose>
                                <c:when test="${tip.tip_isKnot == 1}">结贴</c:when>
                                <c:otherwise>未结贴</c:otherwise>
                            </c:choose>-->
								<div th:switch="${tip.tipIsknot}">
									<span th:case="1">结贴</span> <span th:case="*">未结贴</span>
								</div>
							</td>
							<td>
								<!-- 这里显示操作按钮 --> <a type="button" class="btn btn-warning"
								th:href="@{toModifyTipPage.do(tipId=${tip.tipId},myTip=${myTip})}">&nbsp&nbsp&nbsp&nbsp修改&nbsp&nbsp&nbsp&nbsp</a>
								<div>
									<a th:if=${(session.user.userType==0||session.user.userType==1)&&tip.tipIsdeleted==1} type="button" class="btn btn-success"
										th:href="@{changeTipStatus.do(tipId=${tip.tipId},opr=2,myTip=${myTip})}">取消删除</a>
									<!-- &opr=2 -->

									<div >
                                        <div th:switch="${myTip}">
                                        <!-- <a th:case="0" type="button" class="btn btn-danger"
                                           th:href="@{changeTipStatus.do(tipId=${tip.tipId},opr=1,myTip=${myTip})}">删除</a> -->
                                        <a th:case="1"  th:if=${tip.tipIsdeleted==0} type="button" class="btn btn-danger"
                                           th:href="@{changeTipStatus.do(tipId=${tip.tipId},opr=1,myTip=${myTip})}">逻辑删除</a>
                                        <a th:case="2" type="button" class="btn btn-danger"
                                           th:href="@{changeTipStatus.do(tipId=${tip.tipId},opr=5,myTip=${myTip})}">永久删除</a>
                                        </div>
                                    </div>
                                    <!--  <a th:if=${myTip==2&&} type="button" class="btn btn-danger"
                                           th:href="@{changeTipStatus.do(tipId=${tip.tipId},opr=5,myTip=${myTip})}">删除</a> -->
								</div>
								<div th:switch="${tip.tipIsknot}">

									<a type="button" th:case="1" class="btn btn-warning"
										th:href="@{changeTipStatus.do(tipId=${tip.tipId},opr=4,myTip=${myTip})}">取消结贴</a>

									<a type="button" th:case="*" class="btn btn-primary"
										th:href="@{changeTipStatus.do(tipId=${tip.tipId},opr=3,myTip=${myTip})}">&nbsp&nbsp&nbsp&nbsp结贴&nbsp&nbsp&nbsp&nbsp</a>
								</div>
							</td>
						</tr>
					<!-- </c:forEach> -->
				</tbody>
			</table>
			<a type="button" class="btn btn-default" style="margin-left: 17%"
				th:href="toMainPage.do">返回</a>

		</div>
	</div>

	<!-- 引入footer文件 -->
	<footer th:replace="_fragments:: footer"></footer>

</body>
</html>